package com.xxxx.traitTest

/**
 * @program: day0303
 * @description: 尽信书，则不如无书
 * @author: CoreDao
 * @create: 2021-03-03 16:26
 * */
trait Play{
  val name = "zs"
  val age = 22
 def play()
}

trait Study{
  val name = "lis"
  val age = 10
  def learn() ={
    println("i im learning")
  }
}


//多继承情况下，存在相同名称的属性，需要在具体类中进行重写
class Person extends Play with Study{

  override val name: String = "hello"
  override val age = 10
  override def play(): Unit = {
    println("happy")
  }
}

object TraitTest {
  def main(args: Array[String]): Unit = {

    val person = new Person()
    person.play()
    person.learn()
  }



}
